package org.test.connectDB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class OracleConn {

	public static void main(String[] args) {
		try {
//			Class.forName("oracle.jdbc.driver.OracleDriver");
//			new OracleDriver();
			String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
			Connection conn = DriverManager
					.getConnection(url, "scott", "tiger");
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery("select * from dept");
			while (rs.next()) {
				System.out.print("DeptNo:" + rs.getInt(1));
				System.out.print("/tDeptName:" + rs.getString(2));
				System.out.println("/tLOC:" + rs.getString(3));
			}
			rs.close();
			stmt.close();
			conn.close();
		} catch (Exception e) {
			System.out.println("找不到指定的驱动程序类");
			e.printStackTrace();
		} /*catch (SQLException e) {
			e.printStackTrace();
		}*/
	}
}